/*
 * @Author: 雷小天 
 * @Date: 2021-11-19 15:12:10 
 * @Last Modified by: 雷小天
 * @Last Modified time: 2021-12-14 10:43:58
 */

<template>
  <div class="layui-container fly-marginTop fly-user-main">
    <UserNav :current=1></UserNav>

  <div class="fly-panel fly-panel-user" pad20>

    <div class="fly-msg" style="margin-top: 15px;">
      您的邮箱尚未验证，这比较影响您的帐号安全，<a href="activate.html">立即去激活？</a>
    </div>
   <div class="layui-row layui-col-space20">
     <div class="layui-col-md6">
       <div class="fly-panel fly-signin fly-panel-border">
         <div class="fly-panel-title">
           签到 <i class="fly-mid"></i>
           <a href="javascript:;" class="fly-link" id="LAY_signinHelp" @click="signinHelp = true">说明</a> <i class="fly-mid"></i>
           <a href="javascript:;" class="fly-link" id="LAY_signinTop" @click="signTop">活跃榜<span class="layui-badge-dot"></span></a>
           <span class="fly-signin-days">已连续签到<cite>{{$store.getters.getSignInfo.signInfo.days}}</cite>天</span>
         </div>
          <div class="fly-panel-main fly-signin-main">
            <template v-if="$store.getters.getSignInfo.is_sign === false">
              <button class="layui-btn layui-btn-danger" @click="signin" id="LAY_signin">今日签到</button>
              <span>可获得<cite>5</cite>飞吻</span>
            </template>
            <!-- 已签到状态 -->
            <template v-else>
              <button class="layui-btn layui-btn-disabled">今日已签到</button>
              <span>获得了<cite>{{$store.getters.getSignInfo.signInfo.reward}}</cite>飞吻</span>
            </template>
          </div>
         </div>
       </div>
      <div class="layui-col-md6">
        <div class="fly-panel fly-panel-border">
          <div class="fly-panel-title"> 我的会员信息 </div>
          <div class="fly-panel-main layui-text" style="padding: 18px 15px; height: 50px; line-height: 26px;">
            <p>您的财富经验值：{{user.reward}}</p>
            <p v-if="user.is_vip>0">您当前为：<i class="layui-badge fly-badge-vip layui-hide-xs">VIP{{user.is_vip}}</i></p>
            <p v-else>您当前为：非 VIP</p>
          </div>
         </div>
       </div>
       <div class="layui-col-md12" style="margin-top: -20px;">
         <div class="fly-panel fly-panel-border">
           <div class="fly-panel-title"> 快捷方式 </div>
           <div class="fly-panel-main">
             <ul class="layui-row layui-col-space10 fly-shortcut">
               <li class="layui-col-sm3 layui-col-xs4"> <a href="/user/set/"><i class="layui-icon"></i><cite>修改信息</cite></a> </li>
               <li class="layui-col-sm3 layui-col-xs4"> <a href="/user/set/#avatar"><i class="layui-icon"></i><cite>修改头像</cite></a> </li>
               <li class="layui-col-sm3 layui-col-xs4"> <a href="/user/set/#pass"><i class="layui-icon"></i><cite>修改密码</cite></a> </li>
               <li class="layui-col-sm3 layui-col-xs4"> <a href="/user/set/#bind"><i class="layui-icon"></i><cite>帐号绑定</cite></a> </li>
               <li class="layui-col-sm3 layui-col-xs4"> <a href="/jie/add/"><i class="layui-icon"></i><cite>发表新帖</cite></a> </li>
               <li class="layui-col-sm3 layui-col-xs4"> <a href="/column/share/"><i class="layui-icon"></i><cite>查看分享</cite></a> </li>
               <li class="layui-col-sm3 layui-col-xs4 LAY_search"> <a href="javascript:;"><i class="layui-icon"></i><cite>搜索资源</cite></a> </li>
               <li class="layui-col-sm3 layui-col-xs4"> <a href="/user/post/#collection"><i class="layui-icon"></i><cite>我的收藏</cite></a> </li>
               <li class="layui-col-sm3 layui-col-xs4"> <a href="/jie/15697/"><i class="layui-icon"></i><cite>成为赞助商</cite></a> </li>
               <li class="layui-col-sm3 layui-col-xs4"> <a href="/jie/2461/"><i class="layui-icon"></i><cite>关注公众号</cite></a> </li>
               <li class="layui-col-sm3 layui-col-xs4"> <a href="http://www.layui.com/doc/"><i class="layui-icon"></i><cite>文档</cite></a> </li>
               <li class="layui-col-sm3 layui-col-xs4"> <a href="http://www.layui.com/demo/"><i class="layui-icon"></i><cite>示例</cite></a> </li>
             </ul>
           </div>
         </div>
       </div>
     </div>

     <el-dialog v-model="signinHelp" title="签到说明" width="300px">
    <div class="layui-text">
        <blockquote class="layui-elem-quote">“签到”可获得社区飞吻，规则如下</blockquote>
        <table class="layui-table">
          <thead>
            <tr><th>连续签到天数</th><th>每天可获飞吻</th></tr>
          </thead>
          <tbody>
            <tr><td>＜5</td><td>5</td></tr>
            <tr><td>≥5</td><td>10</td></tr>
            <tr><td>≥15</td><td>15</td></tr>
            <tr><td>≥30</td><td>20</td></tr>
          </tbody>
        </table>
        <ul>
          <li>中间若有间隔，则连续天数重新计算</li>
          <li style="color: #FF5722;">不可利用程序自动签到，否则飞吻清零</li>
        </ul>
      </div>
  </el-dialog>


  </div>
</div>
</template>

<script>
import UserNav from './UserNav.vue'
import request from '@/utils/request'
import Cookies from 'js-cookie'
import { ElMessage } from 'element-plus'
import { mapState } from "vuex";
export default {
  components: {
     UserNav,
  },
  data() {
    return {
      id: 0, //ID
      title: "", //标题
      address: "bbs.100txy.com", //地址
      data: {
        user_info: {}
      }, //帖子详情
      comment: [], // 帖子评论列表
      isSign: false,
      signinfo: {
        days:0
      },
      signinHelp: false,
    };
  },
  mounted(){
    console.log(this.$route)
    console.log("id:",this.$route.params.id)
    this.getUserSign()
    // this.getDetail(this.$route.params.id) //获取帖子详情
  },
  setup(){
    console.log("setup start")
    myFn()
    function myFn(){
      console.log("aaa");
    }
    return {
      myFn
    }
  },
  computed: {
      ...mapState(["user"])
  },
  methods: {
    //获取帖子详情
    getDetail(id) {
      const params = {
        params: {
        }
      }
      request.get('/micro-bbs/v1/post/'+id, params).then((res) => {
        const { code, data } = res
        // this.notifySucceed(message);
        if (code === 200) {
          this.title = data.title
          this.data = data.data
          this.comment = data.comment
        }
      })
    },
    //获取用户签到
    getUserSign(){
      if(Cookies.get('app.token') != ""){
         const params = {
        params: {
        }
      }
      request.get('/micro-bbs/v2/members/signinfo', params).then((res) => {
        const { code, data } = res
        if (code === 200) {
          console.log("data:",data)
          // this.isSign = data.is_sign
          // this.signinfo = data.signInfo
          this.$store.commit('setSignInfo',data)
        }else{
          //未签到不处理
        }
      })
      }
    },
    signTop(){
      ElMessage({
        message: '暂未开通',
        type: 'warning',
        offset: 200
      })
    }
  }
}
</script>